package StringJoiner_package;

import java.util.StringJoiner;

public class StringJoiner_demo2 {
    public static void main(String[] args) {
        //1、创建对象
        StringJoiner sj = new StringJoiner(",", "[", "]");

        //2、添加元素
        sj.add("a").add("b").add("c").add("d");

        int len = sj.length();
        System.out.println(len);//9

        //3、打印
        System.out.println(sj);//[a,b,c,d]

        String str = sj.toString();
        System.out.println(str);//[a,b,c,d]
    }
}
